package com.shiguo365.market.presenter.implement;

import android.app.Activity;
import android.support.annotation.NonNull;
import android.util.Log;

import com.alibaba.fastjson.JSONObject;
import com.shiguo365.market.application.MyApplication;
import com.shiguo365.market.display.view.IOrderView;
import com.shiguo365.market.display.view.IOrderView;
import com.shiguo365.market.presenter.contract.IOrderPresenter;

import java.util.List;

import biz.yfsoft.api.ae.api.AEClient;
import biz.yfsoft.api.ae.api.AEParam;
import biz.yfsoft.api.ae.api.BaseAECallback;

/**
 * Created by caomenglong on 16/8/12.
 */
public class OrderPresenter implements IOrderPresenter {
    private static final String TAG = "OrderPresenter";
    private final Activity mActivity;
    private final IOrderView mOrderView;

    public OrderPresenter(@NonNull Activity activity, @NonNull IOrderView orderView) {
        this.mActivity = activity;
        this.mOrderView = orderView;
    }

    @Override
    public void getOrderByUI(Integer uid,String status) {
        AEClient _client = new AEClient("shiguo.order.getOrderListByStatus");
        AEParam aeParam=new AEParam();
        aeParam.set("uid",uid);
        aeParam.set("status",status);
        _client.call(aeParam,new BaseAECallback() {
            @Override
            public void onStart() {
            }

            @Override
            public void onSuccess(List<JSONObject> jsonObjectList) {
                Log.d(TAG,"onSuccess:"+jsonObjectList.toString());
                mOrderView.OnGetOrderOK(jsonObjectList);
            }

            @Override
            public void onError( String errno, String message) {
                Log.e(TAG,"onFailure ......." + errno);
            }

            @Override
            public void onFinally(String s) {
                mOrderView.OnGetOrderFinsh();
            }
        });

    }
}
